package com.vueperson.vueperson.services.handle;

import com.vueperson.vueperson.dao.AlbumDao;
import com.vueperson.vueperson.dao.FenleiDao;
import com.vueperson.vueperson.entity.Album;
import com.vueperson.vueperson.entity.Fenlei;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class AlbumFenlei {
    @Autowired
    AlbumDao albumDao;
    @Autowired
    FenleiDao fenleiDao;
    public void t01(){
        Fenlei fenlei = new Fenlei(1,"fenlei",null);
        Fenlei fenlei2 = new Fenlei(2,"fenlei2",null);
        List<Fenlei> fenleis = new ArrayList<>();
        fenleis.add(fenlei);
        fenleis.add(fenlei2);
        Album album = new Album(1,fenleis);
        albumDao.save(album);//如果只执行上面这些;数据库中的fenlei表数据为空，album表有一条数据，album_fenlei有两条数据<br>//如果加上下面这些；数据库中的fenlei表 有两条数据
                fenleiDao.save(fenlei);
        fenleiDao.save(fenlei2);
    }


}
